/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.patpro.controladores;

import com.patpro.modelo.javabeans.Alumno;
import com.patpro.modelo.javabeans.SemestreAcademico;
import com.patpro.modelo.servicios.AlumnoNotaService;
import com.patpro.modelo.servicios.AlumnoServicio;
import com.patpro.modelo.servicios.SemestreAcademicoService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**

 */
public class ListarCursosNotasSemestreController extends AbstractController {

    private SemestreAcademicoService servicio_semestre;
    private AlumnoNotaService servicio_alumnonota;
    private AlumnoServicio servicio_alumno;

    public void setServicio_alumno(AlumnoServicio servicio_alumno) {
        this.servicio_alumno = servicio_alumno;
    }

    public SemestreAcademicoService getServicio_semestre() {
        return servicio_semestre;
    }

    public void setServicio_semestre(SemestreAcademicoService servicio_semestre) {
        this.servicio_semestre = servicio_semestre;
    }

    public void setServicio_alumnonota(AlumnoNotaService servicio_alumnonota) {
        this.servicio_alumnonota = servicio_alumnonota;
    }

    public ListarCursosNotasSemestreController() {
    }
    
    protected ModelAndView handleRequestInternal(
            HttpServletRequest request, 
            HttpServletResponse response) throws Exception {

        Alumno a = servicio_alumno.buscarAlumnoPorUsuario(request.getRemoteUser());
        String id_semestre =request.getParameter("semestre");
        ModelAndView mv = new ModelAndView("alumno/alumnonotas");
        mv.addObject("lista_semestres", servicio_semestre.listarSemestres());
        //mv.addObject("usuario", p.getNombres_completo());

        if(id_semestre != null){
            mv.addObject("id_semestre", id_semestre);
             mv.addObject("lista_alumnocurso", servicio_alumnonota.listarAlumnoNotaPorSemestreyAlumno(new SemestreAcademico(Integer.parseInt(id_semestre)), a));
        }
        return mv;
    }

}